"""
@name : 多进程
@author : Zhao Junjie
@projectname: pythonProject3
"""
import IPy
from pythonping import ping
from multiprocessing import Process
import threading


def myping(ip):
    res = ping(ip, timeout=1)
    if res.success():
        print(str(ip) + " is up")
    else:
        print(str(ip) + " is down")

# 多进程实现
if __name__ == "__main__":
    ip_net = "192.168.2.0/24"
    ips = IPy.IP(ip_net)
    p_lst = []
    for ip in ips:
        p = Process(target=myping, args=(str(ip),))
        p_lst.append(p)
        p.start()
    for p in p_lst:
        p.join()
    print("扫描完毕")